package com.greensam.pixelengine.pojo.emuns.converter;

import com.greensam.pixelengine.pojo.emuns.SpaceLevelEnum;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

/**
 * @author Ma Chengrui
 * @since 2025/8/2 16:03
 */
@Converter()
public class SpaceLevelEnumConverter implements AttributeConverter<SpaceLevelEnum, Integer> {

    @Override
    public Integer convertToDatabaseColumn(SpaceLevelEnum attribute) {
        return attribute != null ? attribute.getValue() : null;
    }

    @Override
    public SpaceLevelEnum convertToEntityAttribute(Integer dbData) {
        return dbData != null ? SpaceLevelEnum.getByValue(dbData) : null;
    }
}
